<%@page import="model.Action"%>
<%@page import="entity.User"%>
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<% ResultSet rs = Action.select("SELECT idUser,HoTen,Username,Email,idGroup,Active FROM users");


%>
<script>
    function  del(){
        
        if(confirm("Bạn Có Chắc Chắn Muốn Xóa không")){
            return true
        }
        else{return false}

    }

</script>
<style type="text/css">
<!--
.div2       {
	border: 1px solid #CCCCCC;
	clear: left;
	float: right;
	padding: 5px;
	text-align: center;
	margin-top: 5px;
	margin-right: 55px;
	margin-bottom: 5px;
	margin-left: 5px;
}
-->
</style>



<p>&nbsp;</p>
<p align="center" class="titleU">QUẢN LÝ NGƯỜI DÙNG</p>
<p></p>
<div class="div2">
        <form id="form" name="form" method="post" action="/quanlyphonghoc/manage/adduser.jsp">
          
            <input name="add" type="submit" id="add" value="Thêm Người Dùng" />
          
          
        </form>
        
        
</div>
<br />
<table width="90%" border="1" align="center" cellpadding="1" cellspacing="0">
    <tr>
        <td width="26" height="22">STT</td>
        <td width="146" align="center">Họ Và Tên</td>
        <td width="161" align="center">Tên Đăng Nhập</td>
        <td width="160" align="center">E-mail</td>
        <td width="132" align="center">Quyền Hạn</td>
        <td width="130" align="center">Trạng Thái</td>
        <td width="130">&nbsp;</td>
    </tr>
    <%
                int num = 0;
                while (rs.next()) {
                    num++;
    %>
    <tr>
        <td align="center" valign="top"><%=num%></td>
        <td align="left" valign="top"><%=rs.getString("HoTen")%></td>
        <td align="left" valign="top"><%=rs.getString("Username")%></td>
        <td align="left" valign="top"><%=rs.getString("Email")%></td>
        <td align="left" valign="top">
            <% int group = Integer.parseInt(rs.getString("idGroup"));
                        switch (group) {
                            case 1:%>Thành Viên
            <% break;
                                 case 2:%>Quản Lý
            <% break;
                                  default:%> Chưa Xác Định
            <%break;
                        }

            %>        </td>
        <td align="center" valign="top"><% if (rs.getString("Active").equals("1")) {%> Đã Kích Hoạt<%} else {%>Chưa Kích Hoạt<% }%></td>
        <td align="center" valign="top"><form action="/quanlyphonghoc/manage/detailuser.jsp" method="post" name="detailUser" class="form1" id="form2">
                <input type="hidden" name="idUser" id="idUser" value="<%=rs.getString("idUser")%>"/>
                <input type="submit" name="chitiet2" id="chitiet2" value="Chi Tiết" />
            </form>
                <% if(!rs.getString("idGroup").equals("2")){ %>
            <form action="/quanlyphonghoc/deluser" method="post" name="DelUser" class="form2" id="DelUser" onsubmit="return del()">
                <input type="hidden" name="idUser" id="idUser" value="<%=rs.getString("idUser")%>"/>
                <input type="submit" name="chitiet" id="chitiet" value="Xóa"  />
            </form>
                <% }%>
        </td>
    </tr>
    <% }%>
</table>
<br />
<div class="div2">
  <form id="form3" name="form1" method="post" action="/quanlyphonghoc/manage/adduser.jsp">
    <input name="add2" type="submit" id="add2" value="Thêm Người Dùng" />
  </form>
</div>
<p class="title">&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>